package com.example.administrator.printoutindemo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.dds.soap.SoapListener;
import com.dds.soap.SoapParams;
import com.example.administrator.printoutindemo.base.BaseActivity;
import com.example.administrator.printoutindemo.http.SPUtil;
import com.jess.arms.base.BaseConstants;

import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;

/**
 * Created by noc on 2019/4/11.
 */

public class ShenpiResultActivity extends BaseActivity {
    private TextView tv_sfty, tv_fkms, tv_spr, tv_spriqi;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chakan);
        tv_sfty = findViewById(R.id.tv_sfty);
        tv_fkms = findViewById(R.id.tv_fkms);
        tv_spr = findViewById(R.id.tv_spr);
        tv_spriqi = findViewById(R.id.tv_spriqi);
        getAuditingStatus();
    }

    private void getAuditingStatus() {


        String methodName = "GetAuditingStatus";

        SoapParams params = new SoapParams();
        params.put("deliveryId", SPUtil.getString(ShenpiResultActivity.this, "peisongid", ""));

        /**
         * 请求
         */
        soapUtil.callEntry(getUrl(), BaseConstants.NAME_SPACE, methodName, params, new SoapListener() {
            @Override
            public void onSuccess(int statusCode, SoapObject object) {

                String result = object.getProperty(methodName + "Result").toString();
                if (result != null && !result.equals("[]") && !result.equals("anyType{}") && !result.equals("Error") && !result.equals("-100")) {
                    Log.e("dayinfankuijieguo", result);
                    Log.e("chaxun======", result);
                    JSONObject jsonpObject = JSON.parseObject(result);
                    if (jsonpObject.getString("auditingResult") != null) {
                        tv_sfty.setText(jsonpObject.getString("auditingResult"));
                    } else {
                        tv_sfty.setText("");
                    }

                    if (jsonpObject.getString("feedback") != null) {
                        tv_fkms.setText(jsonpObject.getString("feedback"));
                    } else {
                        tv_fkms.setText("");
                    }
                    if (jsonpObject.getString("auditingDate") != null) {
                        tv_spriqi.setText(jsonpObject.getString("auditingDate"));
                    } else {
                        tv_spriqi.setText("");
                    }
                    if (jsonpObject.getString("approval") != null) {
                        tv_spr.setText(jsonpObject.getString("approval"));
                    } else {
                        tv_spr.setText("");
                    }

                } else {

                }

            }

            @Override
            public void onFailure(int statusCode, String content, Throwable error) {
            }

            @Override
            public void onFailure(int statusCode, SoapFault fault) {
            }
        }, getAapiUserName(), getApiPwd());
    }

}
